<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php $this->display('inc_skin.php', 0 , '会员中心 - 在线充值'); ?>
<script type="text/javascript">
$(function(){
	$('form').trigger('reset');
	$(':radio').click(function(){
		var data=$(this).data('bank'),
		box=$('#display-dom');
		
		$('#bank-type-icon', box).attr('src', '/'+data.logo);
		//$('#bank-link', box).attr('href', data.home);
		//$('#bank-account', box).val(data.account);
		//$('#bank-username', box).val(data.username);
		//$('.example2', box).attr('rel', data.rechargeDemo);
		
		if($.cookie('rechargeBank')!=data.id) $.cookie('rechargeBank', data.id, 360*24);
	});
	
	var bankId=$.cookie('rechargeBank')||$(':radio').attr('value');
	$(':radio[value='+bankId+']').click();
	
	$('.copy').click(function(){
		var text=document.getElementById($(this).attr('for')).value;
		if(!CopyToClipboard(text, function(){
			alert('复制成功');
		}));
	});
	
	$('.example2').click(function(){
		var src='/'+$(this).attr('rel');
		if(src) $('<div>').append($('<img>',{src:src,width:'640px',height:'480px'})).dialog({width:630,height:500,title:'充值演示'});
	});

	$( "#pay-dialog-confirm" ).dialog({
		  autoOpen: false,
	      resizable: false,
	      height: "auto",
	      width: 400,
	      modal: true,
	      buttons: {
	        "已完成": function() {
	          $( this ).dialog( "close" );
	          location = '/index.php/cash/rechargeLog';
	        },
	        "取消": function() {
	          $( this ).dialog( "close" );
	        }
	      }
  	});
});

function checkRecharge(){
	if(!this.amount.value) throw('请填写充值金额');
	var amount=parseInt(this.amount.value),
	$this=$('input[name=amount]',this),
	min=parseInt($this.attr('min')),
	max=parseInt($this.attr('max'));
	min1=parseInt($this.attr('min1')),
	max1=parseInt($this.attr('max1'));
	
	if($('input[name=mBankId]').val()==2||$('input[name=mBankId]').val()==3){
		if(amount<min1) throw('支付宝/财付通充值金额最小为'+min1+'元');
		if(amount>max1) throw('支付宝/财付通充值金额最多限额为'+max1+'元');
	}else{
		if(amount<min) throw('充值金额最小为'+min+'元');
		if(amount>max) throw('充值金额最多限额为'+max+'元');

	}
	if(!this.vcode.value) throw('请输入验证码');
	if(this.vcode.value<4) throw('验证码至少4位');
	$( "#pay-dialog-confirm" ).dialog( "open" );
}
function toCash(err, data){
	//console.log(err);
	if(err){
		alert(err)
		$("#vcode").trigger("click");
	}else{
		$(':password').val('');
		$('input[name=amount]').val('');
		$('.biao-cont').html(data);
	}
}
$(function(){
	$('input[name=amount]').keypress(function(event){
		//console.log(event);
		event.keyCode=event.keyCode || event.charCode;
		return !!(
			// 数字键
			(event.keyCode>=48 && event.keyCode<=57)
			|| event.keyCode==13
			|| event.keyCode==8
			|| event.keyCode==9
			|| event.keyCode==46
		)
	});
});

function toShowPayQr(err, data){
	if(err){
		alert(err);
		$("#pay-dialog-confirm").dialog("close");
	}else if(data){
		if(data.errorcode === 0){
			location = data.url;
		}else{
			alert(data.errormsg);
			$("#pay-dialog-confirm").dialog("close");
		}
	}else{
		alert("系统出错,请稍后重试.");
		$("#pay-dialog-confirm").dialog("close");
	}
}
</script>
<script type="text/javascript">
$(function(){
	$('.example2').click(function(){
		var src='/'+$(this).attr('rel');
		if(src) $('<img>',{src:src}).css({width:'640px',height:'480px'}).dialog({width:660,height:500,title:'充值演示'});
	});
	
	//$('.copy').click(function(){
	//	var text=document.getElementById($(this).attr('for')).value;
	//	if(!CopyToClipboard(text, function(){
	//		alert('复制成功');
	//	}));
	//});
});
</script>

<!--//复制程序 flash+js-->

<script language="JavaScript">
function Alert(msg) {
	alert(msg);
}
function thisMovie(movieName) {
	 if (navigator.appName.indexOf("Microsoft") != -1) {   
		 return window[movieName];   
	 } else {   
		 return document[movieName];   
	 }   
 } 
function copyFun(ID) {
	thisMovie(ID[0]).getASVars($("#"+ID[1]).attr('value'));
}
</script>
<script type="text/javascript" src="/skin/js/swfobject.js"></script>
</head> 
 
<body>
<div id="mainbody"> 
<?php $this->display('inc_header.php'); ?>
<div class="pagetop"></div>
<div class="pagemain">
	
    <div class="display biao-cont">
	    
        <?php
				$sql="select * from {$this->prename}bank_list b, {$this->prename}sysadmin_bank m where m.admin=1 and m.enable=1 and b.isDelete=0 and b.id=m.bankId";
				$banks=$this->getRows($sql);
					
				if($banks){?>
				  <form action="/index.php/payqr/submitPay" method="post" target="ajax" onajax="checkRecharge" call="toShowPayQr" dataType="json">

        <h3>在线充值</h3>
       
        <dl class="wjform">
        	<dt>选择充值方式：</dt>
            <dd>
			<?php
				$set=$this->getSystemSettings();
				$count = 0;
								if($banks) foreach($banks as $bank){
							?>
							<div class="bankchoice">
								<input <?php if($count==0){ ?> checked="checked" <?php }?> value="<?=$bank['bankId']?>" type="radio" name="mBankId" data-bank='<?=json_encode($bank)?>' style="width:auto;" />
								<?php echo $bank['name']; ?>
							</div>
							<?php $count++; } ?>
          </dd>
            </dl>
        <p align="center">财务收款      收款人：杨晋勋</p>
        <dl class="wjform">
        	<dt>充值金额：</dt>
          <dd><input name="amount" id="ContentPlaceHolder1_txtMoney" min="<?=$set['rechargeMin']?>" max="<?=$set['rechargeMax']?>" min1="<?=$set['rechargeMin1']?>" max1="<?=$set['rechargeMax1']?>" value=""/><div style="display:inline;" class="spn12">
          </dd>
        </dl>
        <dl class="wjform">
        	<dt>&nbsp;</dt>
            <dd  class="red">[*  最低：<?=$set['rechargeMin']?> 元，最高：<?=$set['rechargeMax']?> 元]</dd>
        </dl>
        <dl class="wjform">
        	<dt>验证码：</dt>
            <dd><input name="vcode" type="text" style="ime-mode: disabled; width: 75px;" /><b class="yzmNum"><img width="58" height="24" border="0" style="cursor:pointer;margin-bottom:0px;" id="vcode" alt="看不清？点击更换" align="absmiddle" src="/index.php/user/vcode/<?=$this->time?>" title="看不清楚，换一张图片" onclick="this.src='/index.php/user/vcode/'+(new Date()).getTime()"/></dd>
        </dl>
        <dl class="wjform">
        	<dt>&nbsp;</dt>
            <dd><input type="button" id='put_button_pass' class="btn darwingbtn" value="去支付"  onclick="$(this).closest('form').submit()">
        <input type="reset" value="重置" class="btn"/></dd>
        </dl>
		</form>
    <?php }else{ ?>
        充值暂停！
    <?php }?>
		
		
    </div>
</div>
<div class="pagebottom"></div>
</div>

<?php $this->display('inc_footer.php'); ?> 
<div id="pay-dialog-confirm" title="充值提示信息">
  <p>
  	<span class="ui-icon ui-icon-alert" style="float:left; margin:12px 12px 20px 0;"></span>
  	充值中....
  </p>
</div>
</body>
</html>
  
   
 